#ifndef	_CRT_CORE_HPP_
#define _CRT_CORE_HPP_

#include <crt_targetos.hpp>

#if 1
#define LIKELY(x)	__builtin_expect(!!(x), 1)
#define UNLIKELY(x)	__builtin_expect(!!(x), 0)
#else
#define	LIKELY
#define	UNLIKELY
#endif

#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif

#ifndef __STDC_CONSTANT_MACROS
#define __STDC_CONSTANT_MACROS
#endif

#ifndef __STDC_LIMIT_MACROS
#define __STDC_LIMIT_MACROS
#endif


#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif

#ifndef __USE_UNIX98
#define __USE_UNIX98
#endif


#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <stdarg.h>
#include <string.h>
#include <wchar.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <stdint.h>
#include <assert.h>
#include <time.h>


#if (TARGET_OS == OS_WINDOWS)
	#include <winosdef.h>
#elif (TARGET_OS == OS_POSIX)
	#include <posixosdef.h>
#elif (TARGET_OS == OS_DARWIN)
	#include <darwinosdef.h>
#endif


#include <crt_common.hpp>
#include <crt_bits.hpp>


#ifndef event_id
typedef unsigned long	event_id;
#endif

#if (TARGET_OS == OS_WINDOWS)
	typedef wchar_t				basic_tchar;
	typedef const wchar_t*		LPSTRING;
	typedef long				atomic_type;
#elif (TARGET_OS == OS_POSIX)
	typedef char				basic_tchar;
	typedef const char*			LPSTRING;
	typedef long				atomic_type;
#elif (TARGET_OS == OS_DARWIN)
	typedef char				basic_tchar;
	typedef const char*			LPSTRING;
	typedef int32_t				atomic_type;
#endif

#if (TARGET_OS == OS_WINDOWS)
	#include <winossysdef.h>
	#include <winsysvar.hpp>
#elif (TARGET_OS == OS_POSIX)
	#include <posixossysdef.h>
	#include <posixsysvar.hpp>
#elif (TARGET_OS == OS_DARWIN)
	#include <darwinossysdef.h>
	#include <darwinsysvar.hpp>
#endif

#define _max(a,b)								((a)>(b)?(a):(b))
#define _min(a,b)								((a)<(b)?(a):(b))
#define clamp(x,a,b)							(_min(b,_max(a,x)))


#endif 
